package com.mine.modules.vm.controller;


import com.mine.common.domain.vo.Result;
import com.mine.modules.vm.domain.query.ActionByLayerQuery;
import com.mine.modules.vm.domain.query.LayerActionQuery;
import com.mine.modules.vm.entity.VmLayerAction;
import com.mine.modules.vm.entity.VmLayerActionInfo;
import com.mine.modules.vm.service.IVmLayerActionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 场景菜单 前端控制器
 * </p>
 *
 * @author xujf
 * @since 2024-10-21
 */
@Slf4j
@Api(tags = "图层操作管理")
@RestController
@RequestMapping("/vm/layer/action")
public class VmLayerActionController {

    @Resource
    private IVmLayerActionService vmLayerActionService;

    @ApiOperation("图层操作列表")
    @RequestMapping(value = "/actionList", method = RequestMethod.GET)
    public Result<?> actionList(LayerActionQuery pageQuery) {
        return vmLayerActionService.actionList(pageQuery);
    }

    @ApiOperation("添加或修改操作")
    @PostMapping(value = "/addOrEditAction")
    public Result<?> addOrEditAction(VmLayerAction vmLayerAction) {
        return vmLayerActionService.addOrEditAction(vmLayerAction);
    }

    @ApiOperation("删除操作")
    @RequestMapping(value = "/deleteAction", method = RequestMethod.DELETE)
    public Result<?> deleteAction(@RequestParam(name = "id", required = true) String id) {
        return vmLayerActionService.deleteAction(id);
    }

    @ApiOperation("批量删除操作")
    @RequestMapping(value = "/deleteBatchAction", method = RequestMethod.DELETE)
    public Result<?> deleteBatchAction(@RequestParam(name = "ids", required = true) String ids) {
        return vmLayerActionService.deleteBatchAction(ids);
    }


    @ApiOperation("图层操作明细列表")
    @RequestMapping(value = "/actionInfoList", method = RequestMethod.GET)
    public Result<?> actionInfoList(@RequestParam(value = "actionId", required = true) String actionId,
            @RequestParam(value = "keywords", required = false) String keywords) {
        return vmLayerActionService.actionInfoList(actionId,keywords);
    }

    @ApiOperation("添加或修改操作明细")
    @PostMapping(value = "/addOrEditActionInfo")
    public Result<?> addOrEditActionInfo(VmLayerActionInfo vmLayerActionInfo) {
        return vmLayerActionService.addOrEditActionInfo(vmLayerActionInfo);
    }

    @ApiOperation("删除操作明细")
    @RequestMapping(value = "/deleteActionInfo", method = RequestMethod.DELETE)
    public Result<?> deleteActionInfo(@RequestParam(name = "id", required = true) String id) {
        return vmLayerActionService.deleteActionInfo(id);
    }

    @ApiOperation("批量删除操作明细")
    @RequestMapping(value = "/deleteBatchActionInfo", method = RequestMethod.DELETE)
    public Result<?> deleteBatchActionInfo(@RequestParam(name = "ids", required = true) String ids) {
        return vmLayerActionService.deleteBatchActionInfo(ids);
    }

    @ApiOperation("通过图层Id获取操作")
    @RequestMapping(value = "/getActionByLayerId", method = RequestMethod.GET)
    public Result<?> getActionByLayerId(ActionByLayerQuery query) {
        return vmLayerActionService.getActionByLayerId(query);
    }

}
